package day7;

import java.util.Arrays;

/**
 * @Author juzipi
 * @Date 2021/6/12 10:47
 * @Info
 */
public class ArrayException {

    public static void main(String[] args) {
        int[] ints = {1, 1, 1, 20};
//        System.out.println(ints[10]);//ArrayIndexOutOfBoundsException 越界

        int[] ints1 = new int[]{111111,2};
        ints1 = null;
//        System.out.println(ints1[1]);//NullPointerException


        int[] arr = {5165, 1, 651, 65, 1, 651, 65, 1, 654, 163, 54, 6, 874, 6894, 69, 85, 6984, 68, 41, 698, 4};

        for (int i = 0; i < arr.length - 1; i++) {
            for (int j = 0; j < arr.length - 1 - i; j++) {
                if (arr[j] > arr[j+1]){
                    int temp = arr[j];
                    arr[j] = arr[j + 1];
                    arr[j + 1] = temp;
                }
            }
        }

        System.out.println(Arrays.toString(arr));

        System.out.println(Arrays.toString(Arrays.copyOf(arr, 10)));

    }

}
